package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * 一次性读取
 */
public class InputStreamDemo2 {
    public static void main(String[] args) {
        try(InputStream inputStream=new FileInputStream("c.txt")){
            byte[] bytes=new byte[1024];
            while(true){//如果数据超过byte的容量会while循环读取多次
                int read = inputStream.read(bytes);
                if(read==-1) break;
                System.out.println(new String(bytes,"utf-8"));
                Thread.sleep(200);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
